package com.ruoyi.web.controller.front;

import com.ruoyi.api.domain.EmailEntity;
import com.ruoyi.api.domain.GuidCateGoriesEntity;
import com.ruoyi.api.service.EmailService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/system/front/email")
public class EmailController extends BaseController {

    @Autowired
    private EmailService emailService;

    @Autowired
    private MongoTemplate mongoTemplate;

    /**
     * 获取所有guid
     */
    @PreAuthorize("@ss.hasPermi('system:user:list')")
    @GetMapping("/list")
    public TableDataInfo list(EmailEntity entity,
                              @RequestParam(value = "pageNum", defaultValue = "0") int pageNum,
                              @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) throws IllegalAccessException {
        startPage();
        // 调用服务层方法，获取分页数据
        Page<EmailEntity> resultPage = emailService.selectList(EmailEntity.class,entity,pageNum-1,pageSize,mongoTemplate);
        // 调用服务层方法，获取分页数据
        // 转换分页结果为 TableDataInfo
        return getDataTable(resultPage.getContent(), resultPage.getTotalElements());
    }


}
